﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MvCameraControl;

namespace CLVisionCameraControl
{
    //海康相机抽象类，实现基础相机接口
    //海康不同系列相机若有公共部分，可以在类中实现
    public abstract class HIKCameraBase : ICLVisionCamera
    {
        public abstract IntPtr HWnd { get; set; }
        public abstract ICLVisionCameraInfo CLVisionCameraInfo { get; set; }
        public abstract bool IsOpen { get; set; }
        public abstract Bitmap OutBMPImage { get; set; }

        public abstract event Action<IImage> EventGrabBackHIKImage;
        public abstract event Action<Bitmap> EventGrabBackBitmapImage;

        public abstract void GetParamExposure(out float exposureTime, out int ErrorCode, out string ErrorText);
        public abstract void GetParamFrameRate(out float frameRate, out int ErrorCode, out string ErrorText);
        public abstract void GetParamGain(out float gain, out int ErrorCode, out string ErrorText);
        public abstract void GetParamPixelFormat(out EnumPixelFormat enumPixelFormat, out int ErrorCode, out string ErrorText);
        public abstract void GetTriggerMode(out EnumTriggerMode enumTriggerMode, out int ErrorCode, out string ErrorText);
        public abstract void GetTriggerSource(out EnumTriggerSource enumTriggerSource, out int ErrorCode, out string ErrorText);

        public abstract void SetParamExposure(float exposureTime, out int ErrorCode, out string ErrorText);
        public abstract void SetParamFrameRate(float frameRate, out int ErrorCode, out string ErrorText);
        public abstract void SetParamGain(float gain, out int ErrorCode, out string ErrorText);
        public abstract void SetParamPixelFormat(EnumPixelFormat pixelFormat, out int ErrorCode, out string ErrorText);
        public abstract void SetTriggerMode(EnumTriggerMode enumTriggerMode, out int ErrorCode, out string ErrorText);
        public abstract void SetTriggerSource(EnumTriggerSource enumTriggerSource, out int ErrorCode, out string ErrorText);
        public abstract void StartGrab(out int ErrorCode, out string ErrorText);
        public abstract void StopGrab(out int ErrorCode, out string ErrorText);




        public abstract void SetAcquisitionContinuesMode(out int ErrorCode, out string ErrorText);
        public abstract void TriggerSoftwareOnce(out int ErrorCode, out string ErrorText);

        public abstract void OpenDeviceBySerialNumber(string serialNumber, out int ErrorCode, out string ErrorText);
        public abstract void OpenDeviceByUserDefinedName(string userDefinedName, out int ErrorCode, out string ErrorText);
        public abstract void CloseDevice(out int ErrorCode, out string ErrorText);


        //海康相机特有的保存图像方法
        public abstract void SaveImageToFile(string filePath, IImage image, EnumImageFormatType imageFormatType, CFAMethod cfaMethod,out int ErrorCode, out string ErrorText);
        public abstract void FeatureLoad(string filePath, out int ErrorCode, out string ErrorText);
        public abstract void FeatureSave(string filePath, out int ErrorCode, out string ErrorText);
        public abstract void OpenDeviceByIp(string cameraIp, string netExport, out int ErrorCode, out string ErrorText);
        public abstract Bitmap AcquireOneFrameImage( out int ErrorCode, out string ErrorText);

        public abstract void AcquireImageContinuous(IntPtr _handle, out int ErrorCode, out string ErrorText);

        public abstract void SetParamValueByFieldName(string fieldName, object value, out int ErrorCode, out string ErrorText);
        public abstract void GetParamValueByFieldName(string fieldName, out object value, out int ErrorCode, out string ErrorText);
        public abstract List<string> GetParamFieldNames(out int ErrorCode, out string ErrorText);
        public abstract List<ICLVisionCameraParameterStruct> GetParamFields(out int ErrorCode, out string ErrorText);
    }
}
